﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using KCL.Code;
using KCL.Code.Business;

namespace KCL.Components
{
    public partial class uscSize : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            btnAddSize.Enabled = dgvSize.Columns[3].Visible = (bool)Session[SessionManager.canCreate];
            dgvSize.Columns[2].Visible = (bool)Session[SessionManager.canModify];

            btnAddThickness.Enabled = dgvThickness.Columns[2].Visible = (bool)Session[SessionManager.canCreate];
            dgvThickness.Columns[1].Visible = (bool)Session[SessionManager.canModify];
        }

        protected void btnAddSize_Click(object sender, EventArgs e)
        {
            if (txtSizeLength.Text.Trim().Length > 0 &&
                txtSizeWidth.Text.Trim().Length > 0)
            {
                Size s = new Size();
                s.length = txtSizeLength.Text.Trim();
                s.width = txtSizeWidth.Text.Trim();
                s.isActive = true;
                SizeServices.Insert(s);
                dgvSize.DataBind();
                dgvSize.PageIndex = dgvSize.PageCount - 1;
            }
        }

        protected void btnAddThickness_Click(object sender, EventArgs e)
        {
            if (txtThickness.Text.Trim().Length > 0)
            {
                Thickness t = new Thickness();
                t.thick = txtThickness.Text.Trim();
                t.isActive = true;
                ThicknessServices.Insert(t);
                dgvThickness.DataBind();
                dgvThickness.PageIndex = dgvThickness.PageCount - 1;
            }
        }
    }
}